﻿<?php
session_start();

include('database.php');

$_SESSION['curPage'] = 'participateToDraw.php';

$isValid = false;

if(isset($_GET['id']))
{
    $_GET['id'] = htmlspecialchars($_GET['id']);

    $query = $db->prepare("SELECT * FROM draw where id = ?");
    $query->execute(array($_GET['id']));

    if($query->rowCount() == 1)
    {
        $data = $query->fetch();

        if($data['status'] == 1)
        {
                $isValid = true;
        }
        else echo '<p>' . $participateToDraw_youCantYetParticipate . '</p>';
    }
    else echo '<p>' . $participateToDraw_invalidDrawing . '</p>';
}

?>

<!DOCTYPE html>
<html>
    <head>
        <title>Diablo 3 Lottery - Tirages</title>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="style.css" />
    </head>
    <body>
        <div class="d_body">
                <?php include("menuBar.php"); ?>

                <?php if($isValid)
                {
                    echo '<h1>' . $participateToDraw_participatingToDrawing . date('d/m/Y H:i', strtotime($data["date"])) . '</h1>';

                ?>
                    <?php include("participationRules.php"); ?>

                    <form method="post" action="doDraw.php?id=<?php echo $_GET['id']; ?>">

                    <table class="participateToDrawCenter">
                        <tr><td><input type="checkbox" name="rulesAccepted" id="rulesAccepted" /> <label for="rulesAccepted"><?php echo $participateToDraw_acceptRules; ?></label></td></tr>
                        <tr><td><input type="submit" value="<?php echo $participateToDraw_participateToDraw; ?>" /></td></tr>
                    </table>
                    
                    </form>
                <?php
                }
                ?>

        </div>
    </body>
</html>